<% content_for :css do %>
  <%= stylesheet_link_tag 'projects_index','designers_show'  %>
<% end %>
<script>
    function projects_by_pay_status(pay_status)
    {
      $('pay_status').value = pay_status;
      $('payed_year').value = '';
      $('stat_started_on').value = '';
      $('stat_end_on').value = '';
      show_projects();
    }
    
    function payed_projects_by_payed_year(year)
    {
      $('pay_status').value = 'payed';
      $('payed_year').value = year;
      $('stat_started_on').value = '';
      $('stat_end_on').value = '';
      show_projects();
    }

   function show_projects()
   {
     <%= remote_function :update => :projects,
                :url => designer_url(@designer) ,
                :with => "$('search_form').serialize()",
                :method => :get,
                :loading => short_loader('projects', :height => 500, :width => 725)
         %>
   }
</script>
<div class="left corner">
  <div class="designer">
    <div class='logo'>
      <%= image_tag 'unknown.jpg', :width => 190 %>
    </div>
  </div>
  <div class="title">
    发放情况
  </div>
  <div class="body">
    <div class="project">
      <dl>
        <dt><%= link_to_function '待发',"projects_by_pay_status('paying')", :class => 'paying_money' %>：</dt>
        <dd><%= @designer.paying_projects_count %>个</dd>
        <dd class="m"><b>￥</b><%= number_with_precision @designer.paying_total_amount, :precision => 1 %></dd>
      </dl>
      <dl>
        <dt><%= link_to_function '暂缓',"projects_by_pay_status('paused')", :class => 'paused_money' %>：</dt>
        <dd><%= @designer.paused_projects_count %>个</dd>
        <dd class="m"><b>￥</b><%= number_with_precision @designer.paused_total_amount, :precision => 1 %></dd>
      </dl>
      <dl>
        <dt><%= link_to_function '已发',"projects_by_pay_status('payed')", :class => 'payed_money' %>：</dt>
        <dd><%= @designer.payed_projects_count %>个</dd>
        <dd class="m"><b>￥</b><%= number_with_precision @designer.payed_total_amount, :precision => 1 %></dd>
        <% @designer.stat_by_payed_on.each do |stat| %>
        <dd class='year'>
            <dl>
              <dt><%= link_to_function "#{stat.year}年","payed_projects_by_payed_year(#{stat.year})", :title => '发放年' %></dt>
              <dd><%= stat.has_payed_projects_count %>个</dd>
              <dd class='m'><b>￥</b><%= number_with_precision stat.has_payed_total_amount, :precision => 1 %></dd>
            </dl>
         </dd>
      <% end %>
      </dl>
    </div>
  </div>
  <div class="total">
    <dl>
      <dt>
        <%= link_to_remote '共计',
                  :update => :projects,
                  :url => designer_url(@designer) ,
                  :method => :get,
                  :loading => short_loader('projects', :height => 500, :width => 725)
        %>：
      </dt>
      <dd><%= @designer.projects_count %>个</dd>
      <dd class="m"><b>￥</b><%= number_with_precision @designer.total_amount, :precision => 1 %></dd>
    </dl>
  </div>
</div>
<div class="right corner">
  <div class="head">
    <div id="title" class="title"><%= @designer.full_name %>的项目提成</div>
    <div id="search_bar" class="search" style="display: none;">
      <div>
      <% form_tag '#', :id => :search_form do %>
        <b>从</b><%=
            calendar_field( :stat,
                :started_on , {
                  :class => 'date'
                },{
                  :firstDay => 1,
                  :step => 1,
                  :showOthers => true
                }) %>
      <b>到</b><%=
            calendar_field( :stat,
                :end_on , {
                  :class => 'date'
                },{
                  :firstDay => 1,
                  :step => 1,
                  :showOthers => true
                }) %>
      <%= hidden_field_tag :pay_status %>
      <%= hidden_field_tag :payed_year %>
      <% end %>
      </div>
      <div class='tools'>
        <%= link_to_function '查询', 'show_projects()', :class => :base_i %>
      </div>
    </div>
    <div class="tools">
      <div id="print"></div>
    </div>
  </div>
  <div id="projects">
    <%= render :file => 'designers/show.js' %>
  </div>
</div>